<template>
  <div class="container">
    <!--数据大屏内容展示区-->
    <div class="screen" ref="ScreenVc">
      <div class="top">
        <top-component/>
      </div>
      <div class="bottom">
        <div class="left">
          <LeftTourist class="tourist"/>
          <LeftSex class="sex"/>
          <LeftAge class="age"/>
        </div>
        <div class="center">
          <center-map class="map"/>
          <center-line class="line"/>
        </div>
        <div class="right">
          <RightRank class="rank"/>
          <RightYear class="year"/>
          <RightCounter class="counter"/>
        </div>
      </div>
    </div>

  </div>
</template>

<script setup lang="ts">
import {ref, onMounted} from "vue";
//引入顶部子组件
import TopComponent from "./components/top/topComponent.vue";
//左侧三个子组件
import LeftAge from "./components/bottom/left/age/index.vue";
import LeftSex from "./components/bottom/left/sex/index.vue";
import LeftTourist from "./components/bottom/left/tourist/index.vue";
//中间两个子组件
import CenterMap from "./components/bottom/center/map/index.vue";
import CenterLine from "./components/bottom/center/line/index.vue";
//右侧三个子组件
import RightRank from './components/bottom/right/rank/index.vue';
import RightYear from './components/bottom/right/year/index.vue';
import RightCounter from './components/bottom/right/counter/index.vue';


//数据大屏的dom元素
let ScreenVc = ref<any>();


//挂载完毕 往回拽
onMounted(() => {
  ScreenVc.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
})

//定义大屏缩放比例
const getScale = (w: number = 1920, h: number = 1080) => {
  let ww = window.innerWidth / w;
  let wh = window.innerHeight / h;
  return ww < wh ? ww : wh;
}

//监听视口变化
window.onresize = () => {
  ScreenVc.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
}


</script>

<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background: #001529;
  background-size: cover;

  .screen {
    position: fixed;
    width: 1920px;
    height: 1080px;
    //background: #43e1bd;
    left: 50%;
    top: 50%;
    transform-origin: left top; //设置缩放锚点
  }

  .top {
    width: 100%;
    height: 40px;
  }

  .bottom {
    display: flex;

    .right {
      flex: 1;
    }

    .left {
      flex: 1;
      height: 1040px;
      display: flex;
      flex-direction: column;

      .tourist {
        flex: 1.2;
      }

      .sex {
        flex: 1;
      }

      .age {
        flex: 1;
        margin-bottom: 10px;
      }
    }

    .center {
      margin-top: 40px;
      margin-right: 10px;
      margin-left: 10px;
      margin-bottom: 10px;
      flex: 2;
      display: flex;
      flex-direction: column;

      .map {
        flex: 3;
      }

      .line {
        margin-top: 10px;
        flex: 1;
      }
    }

    .right {
      flex: 1;
      height: 1040px;
      display: flex;
      flex-direction: column;

      .rank {
        flex: 1.2;
        margin-top: 10px;
      }

      .year {
        flex: 1;
        margin: 10px 0;
      }

      .counter {
        flex: 1;
        margin-bottom: 10px;
      }
    }
  }
}
</style>